package com.wiseman.writing;

import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.wiseman.writing.utility.StrokeData;
import com.wiseman.writing.utility.Util;

public class StrokeSeqView extends ImageView {
	
	List<StrokeData> mDataList = null;
	private Paint mFillBlackPaint = null;
	private int mSize;

	public StrokeSeqView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}

	public StrokeSeqView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public StrokeSeqView(Context context) {
		super(context);
		init();
	}
	
	private void init(){
		mFillBlackPaint  = new Paint();
		mFillBlackPaint.setColor(Color.BLACK);
		mFillBlackPaint.setStyle(Style.FILL);
		mFillBlackPaint.setAntiAlias(true);
	}
	

	public void setStrokeSequece(List<StrokeData> seqData, int size){
		mDataList = seqData;
		mSize = size;
	}	
	
	@Override
	protected void onDraw(Canvas canvas) {	

		int x = (getWidth() - mSize) / 2;
		int y = (getHeight() - mSize) / 2;
	
		canvas.translate(x, y);
	
		Util.drawMiRect(canvas,  new Rect(0, 0, mSize, mSize));
			
		for(StrokeData data:mDataList){
			Util.drawStroke(canvas, data, mFillBlackPaint);
		}
		
		//super.onDraw(canvas);
	}

}
